<template>
  <div>
    <van-nav-bar title="京东注册" left-text="返回" left-arrow @click-left="onClickLeft" />

    <van-cell-group inset>
      <van-field v-model="checktel" name="checktel" label="手机号" placeholder="手机号"
        :rules="[{ required: true, message: '请填写手机号' }]" />
    </van-cell-group>
    <div style="margin: 16px;">
      <van-button round block type="primary" native-type="submit" @click="goSendmsg">
        提交
      </van-button>
    </div>
    <span @click="gotologin">已经有账号了？去登陆。</span>
  </div>
</template>

<script>
import { doCheckPhone } from '@/apis/wode';
export default {
  data() {
    return {
      checktel: '12345678909'
    }
  },
  methods: {
    goSendmsg() {
      doCheckPhone({ tel: this.checktel }).then(res => {
        if (res.data.code != 200) {
          return showToast('改手机号已被注册');
        } else {
          console.log(res);
          localStorage.setItem("tel", this.checktel)
          this.$router.push('/register/sendmsg')
        }

      })
    },
    onClickLeft() {
      history.back()
    },
    gotologin(){
      this.$router.push("/login")
    }
  }
}
</script>

<style lang="less" scoped></style>